//
//  EqualSpaceFlowLayout.swift
//  LaiLang
//
//  Created by David on 2017/2/21.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class EqualSpaceFlowLayout: UICollectionViewFlowLayout {
    override init() {
        super.init()
        scrollDirection = .vertical
        minimumLineSpacing = 4
        minimumInteritemSpacing = 4
        sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
    }
    
    override func prepare() {
        super.prepare()
//        let itemCount = collectionView?.numberOfItems(inSection: 0)
        
//        self.itemAttributes = [NSMutableArray arrayWithCapacity:itemCount];
        
//        let xOffset = self.sectionInset.left;
//        let yOffset = self.sectionInset.top;
//        let xNextOffset = self.sectionInset.left;
//        for i in 0..<itemCount!{
//            let indexPath = IndexPath
//        }
//        for (NSInteger idx = 0; idx < itemCount; idx++) {
//            NSIndexPath *indexPath = [NSIndexPath indexPathForItem:idx inSection:0];
//            CGSize itemSize = [self.delegate collectionView:self.collectionView layout:self sizeForItemAtIndexPath:indexPath];
//            
//            xNextOffset+=(self.minimumInteritemSpacing + itemSize.width);
//            if (xNextOffset > [self collectionView].bounds.size.width - self.sectionInset.right) {
//                xOffset = self.sectionInset.left;
//                xNextOffset = (self.sectionInset.left + self.minimumInteritemSpacing + itemSize.width);
//                yOffset += (itemSize.height + self.minimumLineSpacing);
//            }
//            else
//            {
//                xOffset = xNextOffset - (self.minimumInteritemSpacing + itemSize.width);
//            }
//            
//            UICollectionViewLayoutAttributes *layoutAttributes =
//                [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
//            
//            layoutAttributes.frame = CGRectMake(xOffset, yOffset, itemSize.width, itemSize.height);
//            [_itemAttributes addObject:layoutAttributes];  
//        }
    }
    
    override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
        return false
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
